package org.dtrd.modules.shop.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.dtrd.common.util.DateUtils;
import org.dtrd.common.util.StringUtil;
import org.dtrd.config.pay.OrderUtil;
import org.dtrd.modules.shop.entity.bean.PayRefundFlowDetail;


/**
 * <p>
 * 
 * </p>
 *
 * @author xiao
 * @since 2022-06-23
 */
@Getter
@Setter
@TableName("dtrd_ent_rd_pay_refund_flow")
public class DtrdEntRdPayRefundFlow {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 医生ID
     */
    @TableField("flow_doctor_id")
    private Integer flowDoctorId;

    /**
     * 收退款类型：1-收钱，2-退款
     */
    @TableField("flow_type")
    private Integer flowType;

    /**
     * 患者ID
     */
    @TableField("flow_patient_id")
    private Integer flowPatientId;

    /**
     * 患者姓名
     */
    @TableField("flow_patient_name")
    private String flowPatientName;

    /**
     * 患者手机号
     */
    @TableField("flow_patient_mobile")
    private String flowPatientMobile;

    /**
     * 金额
     */
    @TableField("flow_price")
    private Integer flowPrice;

    /**
     * 渠道
     */
    @TableField("flow_channel")
    private String flowChannel;

    /**
     * 退款原因
     */
    @TableField("flow_refund_reason")
    private String flowRefundReason;

    /**
     * 对应订单
     */
    @TableField("flow_order_no")
    private String flowOrderNo;

    /**
     * 血糖仪
     */
    @TableField("flow_glucometer")
    private String flowGlucometer;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

    /**
     * 创建月份
     */
    @TableField("flow_create_month")
    private String flowCreateMonth;

    /**
     * 是否删除
     */
    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    /**
     * 机构编码
     */
    @TableField("org_code")
    private String orgCode;

    public DtrdEntRdPayRefundFlow init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdEntRdPayRefundFlow parseFromDto(PayRefundFlowDetail dto) {
        dataId = dto.getDataId();
        flowDoctorId = dto.getFlowDoctorId();
        flowType = dto.getFlowType();
        flowPatientId = dto.getFlowPatientId();
        flowPatientName = dto.getFlowPatientName();
        flowPatientMobile = dto.getFlowPatientMobile();

        flowPrice = OrderUtil.changeY2F(dto.getFlowPrice());

        flowChannel = dto.getFlowChannel();
        flowRefundReason = dto.getFlowRefundReason();
        flowOrderNo = dto.getFlowOrderNo();
        flowGlucometer = dto.getFlowGlucometer();
        orgCode = dto.getOrgCode();
        if (dto.getDataId() == null) {
            flowCreateMonth = DateUtils.date2Str(DateUtils.short_date_sdf_yd.get());
        }
        return this;
    }


}
